package com.exam.huawei;

import java.util.Scanner;

/**
 * date:
 * description:
 */
public class Solution1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int M = Integer.parseInt(scanner.nextLine().trim());
        int N = Integer.parseInt(scanner.nextLine().trim());
        String[] strs = scanner.nextLine().trim().split(" ");
        char[] chs = new char[N];
        for (int i = 0; i < N; i++) {
            chs[i] = strs[i].charAt(0);
        }
        int[] chips = new int[M];
        int chipnum = 0, count = 0;
        for (int i = 0; i < N; i++) {
            boolean flag = false;
            char ch = chs[i];
            if(ch == 'A'){
                for (int j = 0; j < M; j++) {
                    if(chips[j] < 4){
                        chips[j]++;
                        chipnum = j + 1;
                        count = chips[j];
                        flag = true;
                        break;
                    }
                }
            }else{
                for (int j = 0; j < M; j++) {
                    if(chips[j] == 0){
                        chips[j] = 4;
                        chipnum = j + 1;
                        count = 1;
                        flag = true;
                        break;
                    }
                }
            }
            if(!flag){
                chipnum = 0;
                count = 0;
                break;
            }
        }
        if(count == 0){
            System.out.println(0);
            System.out.print(0);
        }else{
            System.out.println(chipnum);
            System.out.print(count);
        }
    }
}
